package fiuba.algo3.vista;

import javax.swing.*;

import java.util.ArrayList;

public class GManzanas{

	static private int ANCHOCALLE = 15;
	static private int ANCHOMANZANA = 35;

	private ArrayList<JLabel> labels;


	
	public GManzanas(int X, int Y){
		
		labels = new ArrayList<JLabel>();
		
		for(int i = 0; i < X;i++){
			for(int j = 0; j < Y;j++){

				ImageIcon icon;
				icon = createImageIcon("manzana.png");

				JLabel label = new JLabel(icon);
				label.setVisible(true);
				label.setBounds(i*(ANCHOCALLE+ANCHOMANZANA)+ANCHOCALLE,j*(ANCHOCALLE+ANCHOMANZANA)+ANCHOCALLE,ANCHOMANZANA,ANCHOMANZANA);
				this.labels.add(label);
			}
		}
	}
	
	public ArrayList<JLabel> getManzanas(){
		return this.labels;
	}
	
	protected ImageIcon createImageIcon(String path) {
		java.net.URL imgURL = getClass().getResource("images/"+path);
		if (imgURL != null) {
			return new ImageIcon(imgURL);
		} else {
			// No deberia suceder nunca
			System.err.println("no se pudo encontrar la ruta: images/" + path);
		return null;
		}
	}
	
}
